// import config from '../config';
import { ICanvas, ModelConstructor } from '../types';
import CanvasAbstract from './canvasAbstract';
import CellModel from '../model/cell';
import position from '../services/position';
import { CanvasEnum } from '../enum';
import { Cell as CellType } from '../types/index';

class Cell extends CanvasAbstract implements ICanvas {
  model(): ModelConstructor {
    return CellModel;
  }

  render(boardMatrixs: CellType[][]): void {
    this.cteateModeles(boardMatrixs);
    super.renderModels();
  }

  protected cteateModeles(boardMatrixs: CellType[][]) {
    this.models = [];
    position.getActiveCellPosition(boardMatrixs).forEach(position => {
      const Model = this.model();
      const instance = new Model(position.x, position.y);
      this.models.push(instance);
    });
  }
}

export default new Cell(CanvasEnum.cell);
